<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="decorator" content="default" />
<title>附页报告</title>
<script type="text/javascript">
	$(document).ready(
		function() {
			$("#value").focus();
			$("#inputForm")
					.validate(
							{
								submitHandler : function(form) {
									form.submit();
								},
								errorContainer : "#messageBox",
								errorPlacement : function(error, element) {
									$("#messageBox").text("输入有误，请先更正。");
									if (element.is(":checkbox")
											|| element.is(":radio")
											|| element.parent().is(
													".input-append")) {
										error.appendTo(element.parent()
												.parent());
									} else {
										error.insertAfter(element);
									}
								}
							});
	});
	
	function loadSubProject(projectId) {
		if(!projectId) {
			$('#subPro').html('<option value="">请选择单位工程</option>');
			$('#subPro').select2('val','');
			$('#gxh').html('<option value="">请选择管线号</option>');
			$('#gxh').select2('val','');
			return;
		}
		$.post(
			'${ctx}/project/subProject/listSubByPro',	
			{projectId: projectId},
			function(data, textStatus, jqXHR) {
				var html = '<option value="">请选择单位工程</option>';
				for(var i=0;i<data.length;i++) {
					html+= '<option value="'+data[i].id+'">'+data[i].name+'</option>';
				}
				$('#subPro').html(html);
			},'json');
	}
	
	function loadGXHBySub(subProjectId) {
		if(!subProjectId) {
			$('#gxh').html('<option value="">请选择管线号</option>');
			$('#gxh').select2('val','');
			$('#gg').html('<option value="">请选择规格</option>');
			$('#gg').select2('val','');
			return;
		}
		$.post(
			'${ctx}/project/tz/listGXHBySub',	
			{subProjectId: subProjectId},
			function(data, textStatus, jqXHR) {
				var html = '<option value="">请选择管线号</option>';
				for(var i=0;i<data.length;i++) {
					html+= '<option value="'+data[i].gxh+'">'+data[i].gxh+'</option>';
				}
				$('#gxh').html(html);
			},'json');
	}
	
	function loadGGlistBySubGXH(gxh) {
		if(!gxh) {
			$('#gg').html('<option value="">请选择规格</option>');
			$('#gg').select2('val','');
			return;
		}
		var sub = $('#subPro').val();
		if(!sub) {
			showTip("请先选择单位工程",'error');
		}
		$.post(
				'${ctx}/project/tz/listGGBySub',	
				{subProjectId: sub, gxh: gxh},
				function(data, textStatus, jqXHR) {
					var html = '<option value="">请选择规格</option>';
					for(var i=0;i<data.length;i++) {
						html+= '<option value="'+data[i].id+'">'+data[i].id+'</option>';
					}
					$('#gg').html(html);
				},'json');
		
	}
	
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/project/report/mainReport">报告主页</a></li>
		<li class="active"><a href="${ctx}/project/report/subReport">报告附页</a></li>
	</ul>
	<form:form id="inputForm"
		action="${ctx}/project/report/exportViceReport" method="post" class="form-horizontal" target="_blank">
		<common:message content="${message}" />
		<div class="control-group">
			<label class="control-label">工程:</label>
			<div class="controls">
				<select name="projectId" class="input-large required" onchange="loadSubProject(this.value)">
					<option value="">请选择工程</option>
					<c:forEach items="${projectList}" var="p">
						<option value="${p.id}">${p.name}</option>
					</c:forEach>
				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">单位工程:</label>
			<div class="controls">
			<select id="subPro" name="subProjectId" class="input-large required" onchange="loadGXHBySub(this.value)">
				<option value="">请选择单位工程</option>
			</select>
			<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">管线编号:</label>
			<div class="controls">
			<select id="gxh" name="gxh" class="input-large required" onchange="loadGGlistBySubGXH(this.value)">
				<option value="">请选择管线号</option>
			</select>
			<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">规格:</label>
			<div class="controls">
			<select id="gg" name="gg" class="input-large required">
				<option value="">请选择规格</option>
			</select>
			<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">编号:</label>
			<div class="controls">
			<input name="num"  maxlength="50"
					class="required input-large" >
			<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit"
				value="导出" />&nbsp; 
		</div>
	</form:form>
</body>
</html>